Skip to content

Write FLAC STREAMINFO MD5 checksum#906

Merged
chenxiaolong merged 2 commits into
chenxiaolong:masterfrom
PatrykMis:flac-streaminfo-md5
Jul 3, 2026
Merged

Write FLAC STREAMINFO MD5 checksum#906
chenxiaolong merged 2 commits into
chenxiaolong:masterfrom
PatrykMis:flac-streaminfo-md5

Conversation

@PatrykMis

@PatrykMis PatrykMis commented Jul 3, 2026

Copy link
Copy Markdown
Contributor

This updates the FLAC container finalization path to write the STREAMINFO MD5 checksum of the unencoded PCM audio data, as specified by FLAC.

The implementation adds a small optional hook for containers that need metadata derived from encoder input samples. FlacContainer uses it to track the exact interchannel sample count and MD5 digest of the same PCM bytes submitted to MediaCodec.

This keeps the existing crash-resilient behavior: encoded FLAC frames are still written to disk as they are produced, and the STREAMINFO patch is only a finalization step for cleanly closed recordings.

It also replaces the previous EOF presentation timestamp based duration calculation with an exact sample count derived from the PCM input, avoiding small rounding/under-counting errors in the STREAMINFO total samples field.

Signed-off-by: Patryk Miś <foss@patrykmis.com>
@chenxiaolong chenxiaolong self-assigned this Jul 3, 2026
Signed-off-by: Andrew Gunnerson <accounts+github@chiller3.com>

@chenxiaolong chenxiaolong left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

I've added one extra commit (1c315cd) to remove the unused FlacContainer.lastPresentationTimeUs, but otherwise, this looks good to me.

chenxiaolong added a commit that referenced this pull request Jul 3, 2026
Signed-off-by: Andrew Gunnerson <accounts+github@chiller3.com>
@chenxiaolong chenxiaolong merged commit 1c315cd into chenxiaolong:master Jul 3, 2026
1 check passed
@PatrykMis PatrykMis deleted the flac-streaminfo-md5 branch July 3, 2026 19:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants